package io.jee.medusa.util;

import org.springframework.util.StringUtils;

import com.googlecode.htmlcompressor.compressor.HtmlCompressor;

public class HtmlUtils {
	
	/**
	 * @see org.springframework.web.util.HtmlUtils
	 * @param content
	 * @return
	 */
	public static String escapeLow(String content) {
	    if(content==null) return "";       
	    String html = content;
	    html = StringUtils.replace(html, "'", "&apos;");
	    html = StringUtils.replace(html, "\"", "&quot;");
	    //html = StringUtils.replace(html, "\t", "&nbsp;&nbsp;");// 替换跳格
	    //html = StringUtils.replace(html, " ", "&nbsp;");// 替换空格
	    html = StringUtils.replace(html, "<", "&lt;");
	    html = StringUtils.replace(html, ">", "&gt;");
	    return html;
	}
	
	public static String crunch(String html) {
		HtmlCompressor compressor = new HtmlCompressor();
		compressor.setCompressCss(true);
		compressor.setCompressJavaScript(true);
		return compressor.compress(html);
	 }

}
